﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using QualityRpt.Service;
using System.Text;

namespace QualityRPT.include
{
    public partial class cl_left : System.Web.UI.UserControl
    {
        public int cid = 0;
        public DataTable fcTable = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            string pid = Request.Params["Pid"];
            if (pid == null)
            {
                pid = "0";
            }
            string strcid = Request.Params["cid"];
            if (strcid != null && strcid.Trim() != string.Empty)
            {
                cid = Convert.ToInt32(strcid);
            }
            fcTable =  FunctionService.GetList("PARENT_ID ="+pid);
            this.func_repeater.DataSource = fcTable;
            this.func_repeater.DataBind();
        }
        public string GetMenuLi(object curID)
        {
            StringBuilder sbrt = new StringBuilder();
            if (curID != DBNull.Value)
            {
                DataRow[] selRow = fcTable.Select("ID="+curID.ToString());
                if (selRow.Length > 0)
                {
                    DataRow cRow = selRow[0];
                    sbrt.Append("<li");
                    if ((int)curID == cid)
                    {
                        sbrt.Append(" class='active'");
                    }
                    sbrt.Append(">");
                    sbrt.Append("<a href='" + cRow["MODULE_URI"].ToString() + "?pid=" + cRow["PARENT_ID"].ToString() + "&cid=" + curID + "'>");
                    sbrt.Append("<span class='hidden-tablet'>" + cRow["MODULE_NAME"].ToString() + "</span>");
                    sbrt.Append("</a>");
                    sbrt.Append("</li>");
                }
            }
            return sbrt.ToString();
        }
    }
}